#ifndef _ASM_H_
#define _ASM_H_
/*
	Copyright (C) 2010 Salil Bhagurkar

	This file is part of salil64

	salil64 is free software: you can redistribute it and/or modify
	it under the terms of the GNU Lesser General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	salil64 is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public License
	along with salil64.  If not, see <http://www.gnu.org/licenses/>.
*/


extern void _intHandler();
extern unsigned long _kernelEnd;
extern unsigned long _kernelStart;
extern unsigned long _kernelBss;
extern void _moveToUserMode();
extern void _moveToUserModeNoInterrupts();
extern void _gdtFlush();
extern void _tssFlush();


/*
 * Parameter passing: rdi, rsi, rdx, rcx, r8, r9
 */
extern void _doSysCall(unsigned long index, unsigned long param1, unsigned long param2,
	unsigned long param3, unsigned long param4, unsigned long param5);

static inline void haltProcessor()
{
	asm volatile("hlt");
}

/*
 * Tables from asm code
 * Initialized to enter long mode: 16 kB of stuff
 */
extern unsigned long _pml4, _pdpt, _pd, _pt;

static inline void enableInterrupts()
{
	asm volatile("sti");
}

static inline void disableInterrupts()
{
	asm volatile("cli");
}

#endif
